import { Message } from 'element-ui';
import {fetch} from '../config/fetch.js'

export function toast(str, num, showClose, onClose){
	if(num == 1){
		var type = 'success';
	}else if(num == 2){
		var type = 'error';
	}else if(num == 3){
		var type = 'warning';
	}else{
		var type = 'info';
	}
	if(showClose){
		Message({
          showClose: true,
          message: str,
          type: type,
          duration: 3000,
          onClose: onClose
        });
	}else{
		Message({
          showClose: false,
          message: str,
          type: type,
          duration: 1000
        });
	}
}//全局toast方法

export function imageError(num, event){
	if(num == 1){
		event.target.src=require("../assets/img/shangpin_moren@2x.png");
	}else if(num == 2){
		event.target.src=require("../assets/img/shouye_banner_moren@2x.png");
	}else if(num == 3){
		event.target.src=require("../assets/img/pinpailogo_moren@2x.png");
	}else if(num == 4){
		event.target.src=require("../assets/img/touxiang_moren@2x.png");
	}else if(num == 5){
		event.target.src=require("../assets/img/dingbu_banner_moren@2x.png");
	}else if(num == 6){
		event.target.src=require("../assets/img/huodongshangpin_xinqite_moren@2x.png");
	}		
}//全局图片加载失败方法